/**
 * 年龄与出生日期联动，已经年龄单位，岁/月/天/周/小时/分； age.js
 */
// 根据年龄计算出生日期

//绑定事件（年龄，“出生日期”、单位, 身份证号）
function ageChangeBind(ageid, bid, dwid, Cardid) {
    debugger;
    $("#" + bid).on("blur", function () {
        debugger;
        handsOn(ageid, bid, dwid);
    })
    $("#" + ageid).on("input", function () {
        debugger;
        getBirthDayByAge(ageid, bid, dwid);
    })
    $("#" + dwid).on("change", function () {
        debugger
        getBirthDayByAge(ageid, bid, dwid);
    })
    $("#" + Cardid).on("blur", function () {
        debugger;
        var card = /^[a-zA-Z][0-9]{9}$/;//台湾身份证号验证
        var xianggangreg = /^[A-Za-z][0-9]{6}\([0-9a-zA-Z]\)$/;
        var aomenreg = /^[157][0-9]{6}\([0-9]\)$/;
        var num = $('#' + Cardid).val();
        if (!!num) {
            if (verfyCertificat(num)) {
                var bidtext;
                if (num.length == 18) {
                    bidtext = num.substring(6, 14)
                } else {
                    bidtext = "19" + num.substring(6, 12);
                }
                $("#" + bid).val(bidtext);
                $("#" + bid).trigger("blur");
            } else {
                if (!card.test($("#" + Cardid).val()) && !xianggangreg.test($("#" + Cardid).val()) && !aomenreg.test($("#" + Cardid).val())) {
                    layer.tips('身份证不正确，请重新输入', '#' + Cardid);
                }

            }
        }
    })
}
//根据年龄计算出生日期传三个参数，（年龄id/出生日期id/年龄单位id）
function getBirthDayByAge(ageid, bid, dwid)
{
    debugger;
    var fiFlag = false;
    var nowDate = moment(new Date()).format("YYYY-MM-DD HH:mm:ss");
    var intBeginYear = parseInt(nowDate.substring(0, 4), 10);
    var intBeginMonth = parseInt(nowDate.substring(nowDate.indexOf("-") + 1, nowDate.indexOf("-") + 3), 10);
    var intBeginDate = parseInt(nowDate.substring(nowDate.lastIndexOf("-") + 1, nowDate.lastIndexOf("-") + 3), 10);
    var age = $("#" + ageid).val();
    var monthDef = Math.round(12 * age);
    var unit = $("#" + dwid).val();
    var param = {};
    param.ageid = ageid;
    param.bid = bid;
    param.dwid = dwid;
    param.age = age;
    param.intBeginYear = intBeginYear;
    param.intBeginMonth = intBeginMonth;
    param.intBeginDate = intBeginDate;
    if (unit == "Y") {
        var byYearForAge = getBirthday(nowDate, monthDef, fiFlag);
        $("#" + bid).val(byYearForAge);
    }
    else if (unit == "D") {
        MathDayToAge(param);
    }
    else if (unit == "M") {
        MathMounthToAge(param);
    }
}
/**
 * 根据单位天计算出生日期
 * @param param
 */
function MathDayToAge(param){
    debugger;
    var Feb;
    var isleap = isLeapYear(param.intBeginYear);
    if(isleap){
        Feb = 29;
    }else{
        Feb = 28;
    }
    var bigArr = [1, 3, 5, 7, 8, 10, 12];
    var smallArr = [4, 6, 9, 11];
    param.bigArr = bigArr;
    param.smallArr = smallArr;
    param.Feb = Feb;
    var result = param.intBeginDate - param.age + 1;
    var ageYear, ageMonth, ageDay;
    if (result > 0) {
        ageYear = param.intBeginYear;
        ageMonth = param.intBeginMonth;
        ageDay = result;
    }
    else {
        //把天数换算为几个月几天的格式(9个月8天)
        var daycount = 0;
        var $ageMonth = parseInt(param.age / 30); //几个月
        var $ageDay = param.age % 30; //几天
        if ($ageMonth < param.intBeginMonth) {
            var endMonth = parseInt(param.intBeginMonth - $ageMonth); //计算在第几个月
            for (var i = endMonth; i < param.intBeginMonth; i++) {
                if ($.inArray(i, bigArr) >= 0) {      //
                    daycount += 31;
                } else if ($.inArray(i, smallArr) >= 0) {
                    daycount += 30;
                } else {
                    daycount += Feb;
                }
            }
            ageYear = param.intBeginYear;
            ageMonth = endMonth;
            if ((daycount + $ageDay) >= param.age) {
                ageDay = param.intBeginDate + (daycount - $ageMonth * 30) - $ageDay + 1;
            } else {
                ageDay = param.intBeginDate - (daycount - $ageMonth * 30) - $ageDay;
            }
            if (ageDay <= 0) {
                ageMonth = endMonth - 1;
                if (ageMonth == 0) {
                    ageYear = ageYear - 1;
                    ageMonth = 12;
                }
                if ($.inArray(ageMonth, bigArr) >= 0) {      //
                    ageDay += 31;
                } else if ($.inArray(ageMonth, smallArr) >= 0) {
                    ageDay += 30;
                } else {
                    ageDay += Feb;
                }
            }
        }
        else {
            var daycount = 0;
            var surMonth = $ageMonth - parseInt(param.intBeginMonth);  // 计算剩的下月，不精确，因为$ageMonth是根据每个月30天估算的
            var consumYear = parseInt(surMonth / 12); //几年 0 1
            var consumMounth = parseInt(surMonth % 12);  //几个月 0 - 11
            if (consumYear == 0 && consumMounth > 0) { //  1-----------------------------------------给年份
                ageYear = param.intBeginYear - 1;

            }
            else if (consumYear > 0 && consumMounth > 0) {
                ageYear = param.intBeginYear - consumYear - 1;
            } else if (consumYear == 0 && consumMounth == 0 && $ageDay > 0) {
                ageYear = param.intBeginYear - 1;
            }
            else if(consumYear == 0 && consumMounth ==0 && $ageDay==0){
                ageYear = param.intBeginYear - 1;
            }
            else {
                ageYear = param.intBeginYear - consumYear;
            }
            //先计算中间的年的总天数 比如从2015.6 - 2017-7 ，2016 就是中间的整年数
            for (var k = ageYear + 1; k < param.intBeginYear; k++) {
                var isleap1 = isLeapYear(k);
                daycount += isleap1 ? 366 : 365;
            }
            //再计算本年的天数 ，这个时候没有加本年本月截止今天的天数，就是param.intBeginDate；
            for (var n = 1; n < param.intBeginMonth; n++) {
                if ($.inArray(n, bigArr) >= 0) {      //
                    daycount += 31;
                } else if ($.inArray(n, smallArr) >= 0) {
                    daycount += 30;
                } else {
                    daycount += Feb;
                }
            }
            daycount += param.intBeginDate; //这个时候没有加本年本月截止今天的天数，就是param.intBeginDate；
            param.ageYear = ageYear;
            param.daycount = daycount;
            param.ageMonth = ageMonth;
            if (daycount > param.age) { //传过来的总天数已经比用户输入的大，那么我们回退一年， 找准确的月份

                backYear(param);

            }
            var Calculate = MonthOfAgeCalculate(param);
            ageMonth = Calculate.ageMonth;
            ageDay = Calculate.daycount - Calculate.age; //  3-----------------------------------------给天数
            ageYear = Calculate.ageYear; //  1-----------------------------------------给年重新赋值
        }

    }

    if (ageMonth < 10) {
        ageMonth = "0" + ageMonth;
    }
    if (ageDay < 10) {
        ageDay = "0" + ageDay;
    }
    var barthday = ageYear + "-" + ageMonth + "-" + ageDay + " 00:00:00";
    $("#" + param.bid).val(barthday);
}
//递归回退年
function backYear(param){
    var isleap1 = isLeapYear(param.ageYear + 1);
    param.ageYear = param.ageYear + 1;
    param.daycount -= isleap1 ? 366 : 365;
    if (param.daycount > param.age) {
        backYear(param);
    } else {
        return param;
    }
}

//根据当前用户输入的年龄计算具体的月份
function MonthOfAgeCalculate(param){
    if (parseInt(param.daycount) <= parseInt(param.age)) {//等号一定要要，因为我们要的是比他下的值。等于会让日期变为0
        for (var i = 12; i > 0; i--) { //在循环中给一个形似值，最接近用户输入的值；并且取得当前是第几个月
            if ($.inArray(i, param.bigArr) >= 0) {      //
                param.daycount += 31;
            } else if ($.inArray(i, param.smallArr) >= 0) {
                param.daycount += 30;
            } else {
                param.daycount += param.Feb;
            }
            if (param.daycount > param.age) { //这个是最接近用户输入的值
                param.ageMonth = i; //2 -----------------------------------------------------记录月份；
                break;
            }
        }
        if (param.daycount <= param.age) {
            param.ageYear = param.ageYear - 1;
            MonthOfAgeCalculate(param);
        }
    }
    return param;
}



/**
 * 根据单位为月计算出生日期
 */
function MathMounthToAge(param){
    var monthresult = param.intBeginMonth - param.age;
    var ageYear, ageMonth;
    if (monthresult > 0) {
        ageYear = param.intBeginYear;
        ageMonth = monthresult;
    }
    else {
        if (param.age / 12 > 0) {
            var $ageYear = parseInt(param.age / 12);
            var $ageMonth = param.intBeginMonth - param.age % 12;
            if ($ageMonth > 0) {
                ageMonth = $ageMonth;
                ageYear = param.intBeginYear - $ageYear;
            } else {
                ageMonth = param.intBeginMonth + 12 - param.age % 12;
                ageYear = param.intBeginYear - $ageYear - 1;
            }
        } else {
            ageYear = param.intBeginYear - 1;
            ageMonth = param.intBeginMonth + 12 - param.age % 12;
        }
    }
    if (ageMonth < 10) {
        ageMonth = "0" + ageMonth;
    }
    if (param.intBeginDate < 10) {
        param.intBeginDate = "0" + param.intBeginDate;
    }
    var barthday = ageYear + "-" + ageMonth + "-" + param.intBeginDate + " 00:00:00";
    $("#" + param.bid).val(barthday);
}
/**
 * 跟据月龄推算生日
 */
function getBirthday(nowDate, monthDef, fiFlag)
{
    var intBeginYear = parseInt(nowDate.substring(0, 4), 10);
    // 从"-"后截取月数
    var intBeginMonth = parseInt(nowDate.substring(nowDate.indexOf("-") + 1, nowDate.indexOf("-") + 3), 10);
    var intBeginDate = parseInt(nowDate.substring(nowDate.lastIndexOf("-") + 1, nowDate.lastIndexOf("-") + 3), 10);
    // 年差推算年份
    var yearBet = parseInt(monthDef / 12, 10);
    var year = intBeginYear - yearBet;
    if(intBeginMonth < 10){
        intBeginMonth = "0"+intBeginMonth;
    }
    if (intBeginDate < 10) {
        intBeginDate = "0" + intBeginDate;
    }
    var resultDate1 = year + "-" + intBeginMonth + "-" + intBeginDate + " 00:00:00";
    return resultDate1;
}
//根据输入的出生日期计算年龄，参数（年龄ID/出生日期id/单位ID）
function yearDef(ageid, bid, dwid){
    debugger;
    var birthDayDate=$("#"+bid).val();
    var nowDate=moment(new Date()).format("YYYY-MM-DD HH:mm:ss");
    var param = {};
    param.ageid = ageid;
    param.bid = bid;
    param.dwid = dwid;
    param.birthDayDate = birthDayDate;
    param.nowDate = nowDate;
    debugger;
    if(birthDayDate){
        // 输入日期
        // 文本框中输入的日期
        var intBeginYear = parseInt(birthDayDate.substring(0, 4));
        // 从"-"后截取月数
        var intBeginMonth = parseInt(birthDayDate.substring(birthDayDate.indexOf("-") + 1, birthDayDate.indexOf("-") + 3),10);
        var intBeginDate = parseInt(birthDayDate.substring(birthDayDate.lastIndexOf("-") + 1, birthDayDate.lastIndexOf("-") + 3),10);
        // 获取到的当前日期
        var intEndYear = parseInt(nowDate.substring(0, 4));
        var intEndMonth = parseInt(nowDate.substring(nowDate.indexOf("-") + 1, nowDate.indexOf("-") + 3),10);
        var intEndDate = parseInt(nowDate.substring(nowDate.lastIndexOf("-") + 1, nowDate.lastIndexOf("-") + 3),10);
        param.intBeginYear = intBeginYear;
        param.intBeginMonth = intBeginMonth;
        param.intBeginDate = intBeginDate;
        param.intEndYear = intEndYear;
        param.intEndMonth = intEndMonth;
        param.intEndDate = intEndDate;
        //校验
        if(intBeginYear==intEndYear && intBeginMonth==intEndMonth && intBeginDate>intEndDate){// 年相同// 月相同// 天不相同
            layer.tips('出生日期不能大于当前时间','#'+bid);
            $("#"+bid).focus();
            $("#"+ageid).val("");
            return false
        }else if(intBeginYear==intEndYear && intBeginMonth>intEndMonth){// 年相同
            // 月不相同
            layer.tips('出生日期不能大于当前时间','#'+bid);
            $("#"+bid).focus();
            $("#"+ageid).val("");
            return false
        }else if(intBeginYear>intEndYear){// 年不相同
            layer.tips('出生日期不能大于当前时间','#'+bid);
            $("#"+bid).focus();
            $("#"+ageid).val("");
            return false
        } else if (intEndYear - intBeginYear > 130) {
            layer.tips('请输入正确的日期', '#'+bid);
            $("#vaa10edit").val("");
            $("#vaa12edit").select();
            return false;
        }
        //选中年龄单位
        var temp = (intEndYear - intBeginYear) * 12 - intBeginMonth + intEndMonth;
        if (param.intBeginMonth == param.intEndMonth) {
            if (param.intBeginDate > param.intEndDate) {
                temp = temp - 1;
            }
        }
        if((intEndYear - intBeginYear < 2)&& temp<12 &&temp>3 ){  //年相减小于2 并且 月数小于12  ---   月
            $("#"+dwid).val("M");
            getMonthAgeByBrithday(param);

        }else if(intEndYear - intBeginYear>0&& temp>=12){   //年
            $("#"+dwid).val("Y");
            getYearAgeByBrithday(param);

        }else if((intEndYear - intBeginYear < 2)&& temp<=3 ){  //天
            $("#"+dwid).val("D");
            getdataAgeByBrithday(param);

        }
    }
}
//根据出生日期计算年
function getYearAgeByBrithday(param){
    var result = param.intEndYear - param.intBeginYear;
    var allYear=0;
    if(param.intBeginMonth>param.intEndMonth){

        allYear=param.intEndYear - param.intBeginYear-1

    } else if (param.intBeginMonth == param.intEndMonth) {
        if (param.intBeginDate > param.intEndDate) {
            allYear=param.intEndYear - param.intBeginYear-1
        } else {
            allYear=param.intEndYear - param.intBeginYear
        }
    } else {
        allYear=param.intEndYear - param.intBeginYear
    }

    $("#" + param.ageid).val(allYear);
}
//根据出生日期计算月
function getMonthAgeByBrithday(param){
    debugger;
    var result = param.intEndYear - param.intBeginYear;
    var allMonth=0;
    if(param.intBeginDate>=param.intEndDate){
        if(result == 0){
            allMonth=param.intEndMonth-param.intBeginMonth;

        }else {
            if(param.intBeginDate>param.intEndDate){  //跨年
                allMonth=(12-param.intBeginMonth)+param.intEndMonth-1;
            }else if(param.intBeginDate<=param.intEndDate){
                allMonth=(12-param.intBeginMonth)+param.intEndMonth;
            }
        }


    } else {
        if(result == 0){
            allMonth = param.intEndMonth - param.intBeginMonth;
        }else{  //跨年
            allMonth = (12 - param.intBeginMonth) + param.intEndMonth;
        }
    }
    $("#" + param.ageid).val(allMonth);
}
//根据出生日期计算天数
function  getdataAgeByBrithday(param){
    debugger;
    var Feb;
    var isleap = isLeapYear(param.intBeginYear);
    if(isleap){
        Feb = 29;
    }else{
        Feb = 28;
    }
    var bigArr = [1,3,5,7,8,10,12];
    var smallArr = [4,6,9,11];
    param.bigArr =bigArr;
    param.smallArr =smallArr;
    param.Feb =Feb;
    var daycount=0;
    var result = param.intEndYear - param.intBeginYear;
    if(result == 0){
        for(var i=param.intBeginMonth ;i<=param.intEndMonth;i++){
            if (i == param.intEndMonth) {
                daycount += param.intEndDate-param.intBeginDate+1;
            } else {
                if($.inArray(i,bigArr)>=0){      //
                    daycount += 31;
                }else if($.inArray(i,smallArr)>=0){
                    daycount += 30;
                }else{
                    daycount += Feb;
                }
            }

        }


    } else {  //跨年
        for(var i=param.intBeginMonth;i<=12;i++){
            if($.inArray(i,bigArr)>=0){      //
                daycount += 31;
            }else if($.inArray(i,smallArr)>=0){
                daycount += 30;
            }else{
                daycount += Feb;
            }
            if(i==param.intBeginMonth){
                daycount = daycount -param.intBeginDate+1;
            }
        }
        for(var k=1 ;k<= param.intEndMonth;k++){

            if(k== param.intEndMonth){
                daycount +=param.intEndDate;
            }else{
                if($.inArray(k,bigArr)>=0){      //
                    daycount += 31;
                }else if($.inArray(k,smallArr)>=0){
                    daycount += 30;
                }else{
                    daycount += Feb;
                }
            }
        }
    }
    $("#" + param.ageid).val(daycount);
}
// 根据输入年龄判断月
function monthYue(param){
    var birthDayDate = param.birthDayDate;
    var nowDate = param.nowDate;
    // 文本框中输入的日期
    var intBeginYear = parseInt(birthDayDate.substring(0, 4));
    // 从"-"后截取月数
    var intBeginMonth = parseInt(birthDayDate.substring(birthDayDate.indexOf("-") + 1, birthDayDate.indexOf("-") + 3), 10);
    var intBeginDate = parseInt(birthDayDate.substring(birthDayDate.lastIndexOf("-") + 1, birthDayDate.lastIndexOf("-") + 3), 10);
    // 获取到的当前日期
    var intEndYear = parseInt(nowDate.substring(0, 4));
    var intEndMonth = parseInt(nowDate.substring(nowDate.indexOf("-") + 1, nowDate.indexOf("-") + 3), 10);
    var intEndDate = parseInt(nowDate.substring(nowDate.lastIndexOf("-") + 1, nowDate.lastIndexOf("-") + 3), 10);

    var Mmonth = intEndMonth + (12 - intBeginMonth);// 判断输入的月数与当前的天数
    var oldName = 12 - intBeginMonth;// 判断输入的月份是不是十二月
    var oldNameMOn = intEndMonth;// 输入月份是十二月份加1然后和当前月份数相加

    if (oldName == 0) {
        $("#" + param.ageid).val(oldNameMOn);

    } else if (intBeginYear == intEndYear) {
        var intbe = (intEndMonth - intBeginMonth);
        $("#" + param.ageid).val(intbe)
        return false;
    } else if (oldName > 0) {
        $("#" + param.ageid).val(Mmonth);

    }
}

//输入日期的时候出发事件（年龄id/ 出生日期id/单位id/）
function handsOn(ageid, bid, dwid) {
    debugger;
    var  bissextileyearmont=/^(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)$/
    var timeTest = /^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s((([0-1][0-9])|(2?[0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/
    if (!timeTest.test($("#" + bid).val()) && $("#" + bid).val() != '') {
        layer.tips('日期格式不符合,请重新输入', '#' + bid);
        $("#" + bid).val('');
        return
    }
    if($("#" + bid).val() &&$("#" + bid).val().split('').length <8){
        layer.tips('日期格式不符合,请重新输入', '#' + bid);
        $("#" + bid).val('');
        return
    }
    var yearFlag = true;
    var brithday = $("#" + bid).val();
    if (!brithday) {
        yearFlag = false;
        return;
    }
    else {
        var date = brithday.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3");
        var datesplit = brithday.split(" ");
        var yemon = /^[12]\d{3}(0\d|1[0-2])([0-2]\d|3[01])$/;
        if (yemon.test(datesplit[0]) || brithday.indexOf(":") > 0) {
            if (brithday.indexOf(":") > 0) {

            }
            else {
                $("#" + bid).val(date + " 00:00:00");
            }

        }
        else {
            if (bissextileyearmont.test(datesplit[0]) == true) {
                $("#" + bid).val(date + " 00:00:00");

            }
            else {
                yearFlag = false;
            }

        }
        if (yearFlag) {
            debugger;

            yearDef(ageid, bid, dwid);
        }
    }
}

function getMonthMaxDay(year, month)
{
    if (month == 4 || month == 6 || month == 9 || month == 11) {
        return 30;
    }
    else if (month != 2) {
        return 31;
    }
    else {
        if (year % 4 == 0 || (year % 100 == 0 && year % 400 == 0)) {
            if (month == 2) {
                return 29;
            }
        }
        else {
            if (month == 2) {
                return 28;
            }
        }
    }
    return 0;
}
/**
 * 计算平年闰年
 */
function isLeapYear(year) {
    var cond1 = year % 4 == 0;  //条件1：年份必须要能被4整除
    var cond2 = year % 100 != 0;  //条件2：年份不能是整百数
    var cond3 = year % 400 ==0;  //条件3：年份是400的倍数
    //当条件1和条件2同时成立时，就肯定是闰年，所以条件1和条件2之间为“与”的关系。
    //如果条件1和条件2不能同时成立，但如果条件3能成立，则仍然是闰年。所以条件3与前2项为“或”的关系。
    //所以得出判断闰年的表达式：
    var cond = cond1 && cond2 || cond3;
    if(cond) {
        return true;
    } else {
        return false;
    }
}
//校验身份证
function verfyCertificat(idCard) {
    //15位和18位身份证号码的正则表达式
    var regIdCard = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
    //如果通过该验证，说明身份证格式正确，但准确性还需计算
    if (regIdCard.test(idCard)) {
        if (idCard.length == 18) {
            var idCardWi = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); //将前17位加权因子保存在数组里
            var idCardY = new Array(1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2); //这是除以11后，可能产生的11位余数、验证码，也保存成数组
            var idCardWiSum = 0; //用来保存前17位各自乖以加权因子后的总和
            for (var i = 0; i < 17; i++) {
                idCardWiSum += idCard.substring(i, i + 1) * idCardWi[i];
            }
            var idCardMod = idCardWiSum % 11;//计算出校验码所在数组的位置
            var idCardLast = idCard.substring(17);//得到最后一位身份证号码
            //如果等于2，则说明校验码是10，身份证号码最后一位应该是X
            if (idCardMod == 2) {
                if (idCardLast == "X" || idCardLast == "x") {
                    return true;
                } else {
                    return false;
                }
            } else {
                //用计算出的验证码与最后一位身份证号码匹配，如果一致，说明通过，否则是无效的身份证号码
                if (idCardLast == idCardY[idCardMod]) {
                    return true;
                } else {
                    return false;
                }
            }
        }
    } else {
        return false;
    }
}
